#include "CollisionManager.h"
#include "Error.h"

namespace Engine
{
	void CollisionManager::RegisterCollisionHandler(const CollidableObjectIDPair& pair, HandlerFunction func)
	{
		if(!m_doubleDispatch.RegisterHandlerFunction(pair, func))
			Error("Collision Handler function already registered with Collision Manager");
	}

	void CollisionManager::RegisterCollidableObject(CollidableObject* obj)
	{
		auto it = m_map.find(obj ->GetGameObjectID());
		if(it != m_map.end()) return;

		m_map[obj ->GetGameObjectID()] = obj;
	}

	void CollisionManager::UnregisterCollidableObject(unsigned int id)
	{
		auto it = m_map.find(id);
		if(it == m_map.end()) return;
		
		m_map.erase(it);
	}
}